package com.bean.xml;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class XmlBeanLoaderTest {

    public static void main(String[] args) {
        // xml方式装载bean
        ApplicationContext context = new ClassPathXmlApplicationContext("xmlContext.xml");

        Student studentA = (Student) context.getBean("studentA");
        System.out.println(studentA.toString());

        Student studentB = (Student) context.getBean("studentB");
        System.out.println(studentB.toString());

        ISchool school = context.getBean(ISchool.class);
        school.ding();
        System.out.println(school.getClass());

        // klass实例
        Klass klass = (Klass) context.getBean("klass");
        for (Student student : klass.students) {
            System.out.println(student.toString());
        }
        klass.school.ding();
    }
}
